<template>
  <div class="app-container">
    <el-card shadow="never">
      <el-row type="flex" class="info-box">
        <div class="order-info">订单编号： <span>{{data.orderId}}</span></div>
        <div class="order-info">运单编号： <span>{{data.id}}</span></div>
        <div class="order-info">下单时间： <span>{{data.created}}</span></div>
        <div class="order-info">订单状态： <span>{{data.schedulingStatus}}</span></div>
        <div class="order-info">预计到达时间： <span>{{data?.order?.createTime }}</span></div>
      </el-row>
    </el-card>

    <info-box title="基本信息">
      <div class="sender">
        <div class="item-header"><img src="../../assets/img/a.png" alt=""/><span>发货方</span></div>
        <div class="sender-item">
          <div>
            <span class="item-name">发货方姓名：</span> <span class="item-desc">{{data?.order?.senderName}}</span>
          </div>
          <div>
            <span class="item-name">发货方电话：</span> <span class="item-desc">{{data?.order?.senderPhone}}</span>
          </div>
        </div>
        <div class="sender-item">
          <div>
            <span class="item-name">发货方地址：</span> <span class="item-desc"></span>
          </div>
          <div>
            <span class="item-name">详细地址：</span> <span class="item-desc">{{}}</span>
          </div>
        </div>
        <div class="sender">
          <div class="item-header"><img src="../../assets/img/b.png" alt=""/><span>收货方</span></div>
          <div class="sender-item">
            <div>
              <span class="item-name">收货方姓名：</span> <span class="item-desc">{{}}</span>
            </div>
            <div>
              <span class="item-name">收货方电话：</span> <span class="item-desc">{{}}</span>
            </div>
          </div>
          <div class="sender-item">
            <div>
              <span class="item-name">收货方地址：</span> <span class="item-desc"></span>
            </div>
            <div>
              <span class="item-name">详细地址：</span> <span class="item-desc">{{}}</span>
            </div>
          </div>
        </div>
      </div>
    </info-box>

    <info-box title="运输信息">
      <el-row>
        <el-steps :space="200" :active="3" finish-status="success">
          <el-step title="皇姑区营业部"></el-step>
          <el-step title="沈阳分拣中心"></el-step>
          <el-step title="武昌营业部"></el-step>
        </el-steps>
      </el-row>
      <el-row>
        <el-col :span="6" class="ydiv">
          <div>
            <span class="item-name">运输任务：</span> <span class="item-desc">{{data?.taskTransports[1]?.id}}</span>
          </div>
          <div>
            <span class="item-name">车辆：</span> <span class="item-desc">{{data?.taskTransports[1]?.truck?.licensePlate}}</span>
          </div>
          <div>
            <span class="item-name">司机：</span> <span class="item-desc">{{data?.taskTransports[1]?.drivers[0]?.name}},<span>{{data?.taskTransports[1]?.drivers[1]?.name}}</span></span>
          </div>
          <div>
            <span class="item-name">到达时间：</span> <span class="item-desc">{{data?.order?.createTime }}</span>
          </div>
        </el-col>
        <el-col :span="6" class="ydiv">
          <div>
            <span class="item-name">运输任务：</span> <span class="item-desc">{{data?.taskTransports[0]?.id}}</span>
          </div>
          <div>
            <span class="item-name">车辆：</span> <span class="item-desc">{{data?.taskTransports[0]?.truck?.licensePlate}}</span>
          </div>
          <div>
            <span class="item-name">司机：</span> <span class="item-desc">{{data?.taskTransports[0]?.drivers[0]?.name}},<span>{{data?.taskTransports[0]?.drivers[1]?.name}}</span></span>
          </div>
          <div>
            <span class="item-name">到达时间：</span> <span class="item-desc">{{data?.order?.createTime }}</span>
          </div>
        </el-col>
      </el-row>
    </info-box>

    <info-box title="基本信息">
      <div class="sender">
        <div class="sender-item">
            <el-table :data="tabdata">
              <el-table-column prop="id" label="序号" width="100"></el-table-column>
              <el-table-column prop="name" label="货物名称" width="100"></el-table-column>
              <el-table-column prop="id" label="货物类型" width="100"></el-table-column>
              <el-table-column prop="totalWeight" label="重量(千克)" width="100"></el-table-column>
              <el-table-column prop="volume" label="体积（立方）" width="100"></el-table-column>
            </el-table>
        </div>
      </div>
    </info-box>
  </div>
</template>
<script>
import { getWaybillDetail } from '@/api/waiball'
import infoBox from '@/components/info-box'

export default {
  components: {
    infoBox
  },
  name: 'OrderDetail',
  data () {
    return {
      data: {},
      tabdata: []
    }
  },
  created () {
    this.getOrderDetail()
  },
  methods: {
    // 获取运单详情
    async getOrderDetail () {
      const res = await getWaybillDetail(this.$route.query.id, { id: this.$route.query.id })
      console.log(res)
      this.data = res.data
      console.log(this.data)
      this.tabdata = res.data.order.orderCargoDTOS
      console.log(this.tabdata)
    }
  }
}
</script>

<style lang="scss" scoped>
.info-box {
  display: flex;
  flex-wrap: wrap;

  .order-info {
    width: 25%;
    padding-left: 20px;
    margin-top: 20px;
    font-size: 14px;

    span {
      color: #818693;
    }
  }

  & .order-info:nth-child(-n+4) {
    margin-top: 0;
  }
}

.info-box {
  margin-top: 20px;
}

.item-header {
  img {
    height: 18px;
    vertical-align: middle;
    margin-left: 2px;
  }

  span {
    margin-left: 10px;
    font-size: 16px;
  }
}

.sender:nth-child(n+2) {
  margin-top: 20px;
}

.sender-item {
  display: flex;
  padding-left: 40px;

  & > div {
    width: 200px;
    margin-top: 10px;

    &:nth-child(2n) {
      margin-left: 174px;
    }
  }
}

.item-desc {
  color: #818693;
}
.ydiv{
  width: 245px;
  height: 135px;
  border-radius: 10px;
  background-color: #f4f8fc;
  padding: 10px;
  margin-right: 50px;
}
</style>
